package com.mightybird.designpattern.behavioral.command.invoker;

import com.mightybird.designpattern.behavioral.command.command.AbstractCommand;

public class CalculatorForm {
    private AbstractCommand command;

    public void setCommand(AbstractCommand command) {
        this.command = command;
    }

    public void compute(int value) {
        int r = command.execute(value);
        System.out.println("执行命令，结果为：" + r);
    }

    public void undo() {
        int r = command.undo();
        System.out.println("执行撤销，结果为：" + r);
    }

    public void redo() {
        int r = command.redo();
        System.out.println("执行重做，结果为：" + r);
    }
}
